]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay/baseAppView: Cleanup animate()
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Wed, 2 Dec 2020 21:02:46 +0000 (18:02 -0300)
committerMarge Bot <marge-bot@gnome.org>
Wed, 2 Dec 2020 22:43:04 +0000 (22:43 +0000)
Simplify the opacity dance to simply setting it to the initial value
before animating (0 when animating in, and 255 when animating out),
and to the final value after the spring animation is done (vice-versa).

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1518>

js/ui/appDisplay.js

index 1fd088ebf02acbf5e7e47799917c079965a7ab15..d1af384d179836538bc4aabaa128446c4bd4beda 100644 (file)
@@ -670,7 +670,6 @@ var BaseAppView = GObject.registerClass({
     }
 
     _doSpringAnimation(animationDirection) {
-        this._grid.opacity = 255;
         this._grid.animateSpring(
             animationDirection,
             Main.overview.dash.showAppsButton);
@@ -688,15 +687,16 @@ var BaseAppView = GObject.registerClass({
     }
 
     animate(animationDirection, onComplete) {
-        if (onComplete) {
-            let animationDoneId = this._grid.connect('animation-done', () => {
-                this._grid.disconnect(animationDoneId);
+        const animationDoneId = this._grid.connect('animation-done', () => {
+            this._grid.disconnect(animationDoneId);
+            this._grid.opacity =
+                animationDirection === IconGrid.AnimationDirection.IN
+                    ? 255 : 0;
+            if (onComplete)
                 onComplete();
-            });
-        }
+        });
 
         this._clearAnimateLater();
-        this._grid.opacity = 255;
 
         if (animationDirection == IconGrid.AnimationDirection.IN) {
             const doSpringAnimationLater = laterType => {
@@ -708,18 +708,18 @@ var BaseAppView = GObject.registerClass({
                     });
             };
 
+            this._grid.opacity = 0;
             if (this._viewIsReady) {
-                this._grid.opacity = 0;
                 doSpringAnimationLater(Meta.LaterType.IDLE);
             } else {
                 this._viewLoadedHandlerId = this.connect('view-loaded',
                     () => {
                         this._clearAnimateLater();
-                        this._grid.opacity = 255;
                         doSpringAnimationLater(Meta.LaterType.BEFORE_REDRAW);
                     });
             }
         } else {
+            this._grid.opacity = 255;
             this._doSpringAnimation(animationDirection);
         }
     }